import os
import configparser

config = configparser.ConfigParser()
config_file = os.getcwd() +'/mqtt.conf'
config.read(config_file)
print(config["server"]["pub_topic"])

# 修改配置文件中参数
with open(config_file, 'w') as c:
    config.set('server', 'pub_topic', "okkkk")
    config.write(c)